package com.simba.server;

import com.simba.GlobalParam;

public class SimbaServer
{
	public static void main(String[] args) throws Exception
	{
		String arg = "";
		if (args.length == 1)
		{
			arg = args[0];
			if (arg.equals("debug"))
			{
				GlobalParam.LOG_MODE = GlobalParam.DEBUG_MODE;
			}
			else if (arg.equals("verbose"))
			{
				GlobalParam.LOG_MODE = GlobalParam.VERBOSE_MODE;
			}
		}

		SimbaServer.preRun(arg);
		// SimbaServer.preRunTest();

		new SimbaServer().run();

	}

	protected static void preRunTest()
	{
		try
		{
			String regexValue = "^([A-Z0-9]{8,})" + "(-(?=\\d{1,3})|N(?=\\d{1,3}S))"
					+ "([1-9]\\d{0,2})" + "(-(?=\\d{1,3}-)|S(?=\\d{1,3}H))" + "([1-9]\\d{0,2})"
					+ "([-|H][A-Za-z0-9]*)$";
			String barcode1 = "AC12345678KL-1-1-12";
			Boolean result = barcode1.matches(regexValue);
			System.out.println("Barcode : [" + barcode1 + "] match result : [" + result + "]");
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}

	}

	private static void preRun(String arg)
	{
		ServerManager.getInstance().setRunMode(arg);
	}

	public SimbaServer()
	{

	}

	public void run()
	{
		this.runClientChannel();
	}

	private void runClientChannel()
	{
		ServerManager.getInstance().init();
	}

}
